﻿using UnityEngine;

public static class Log
{
    private static string EnumToSymbol(Symbol symbol)
    {
        switch (symbol)
        {
            case Symbol.BlackStar:
                return "★";
            case Symbol.WhiteStar:
                return "☆";
            case Symbol.BlackFourPointStar:
                return "✦";
            case Symbol.WhiteFourPointStar:
                return "✧";
            case Symbol.Crosshair:
                return "✢";
            case Symbol.OneSidedBracket:
                return "〉";
            case Symbol.TwoSidedBracket:
                return "﹞";
            case Symbol.Heart:
                return "♡";
            case Symbol.Triangle:
                return "▶";
            case Symbol.Radiation:
                return "☢";
            case Symbol.Error:
                return "⛔";
            case Symbol.Warning:
                return "⚠️";
            default:
                return "▶";
        }
    }

    public static string IntToSymbol(int i)
    {
        switch (i)
        {
            case 0:
                return "★";
            case 1:
                return "☆";
            case 2:
                return "✦";
            case 3:
                return "✧";
            case 4:
                return "✢";
            case 5:
                return "〉";
            case 6:
                return "﹞";
            case 7:
                return "♡";
            case 8:
                return "▶";
            case 9:
                return "☢";
            case 10:
                return "⛔";
            case 11:
                return "⚠️";
            default:
                return "▶";
        }
    }

    #region StandardLog

    public static void log(object obj)
    {
        Debug.Log(obj);
    }

    public static void log(object obj, Color color)
    {
        Debug.Log(string.Format("<color=#{0:X2}{1:X2}{2:X2}>{3}</color>",
            (byte)(color.r * 255f), (byte)(color.g * 255f), (byte)(color.b * 255f), obj));
    }

    public static void log(object obj, Symbol symbol)
    {
        Debug.Log(symbol.ToString() + obj);
    }

    public static void log(object obj, string prefix)
    {
        Debug.Log(prefix + obj);
    }

    public static void log(object obj, Color color, Symbol symbol)
    {
        Debug.Log(EnumToSymbol(symbol) + string.Format("<color=#{0:X2}{1:X2}{2:X2}>{3}</color>",
            (byte)(color.r * 255f), (byte)(color.g * 255f), (byte)(color.b * 255f), obj));
    }

    public static void log(object obj, Color color, string prefix)
    {
        Debug.Log(prefix + string.Format("<color=#{0:X2}{1:X2}{2:X2}>{3}</color>",
            (byte)(color.r * 255f), (byte)(color.g * 255f), (byte)(color.b * 255f), obj));
    }

    #endregion

    #region WarningLog

    public static void logWarning(object obj)
    {
        Debug.LogWarning(obj);
    }

    public static void logWarning(object obj, Color color)
    {
        Debug.LogWarning(string.Format("<color=#{0:X2}{1:X2}{2:X2}>{3}</color>",
            (byte)(color.r * 255f), (byte)(color.g * 255f), (byte)(color.b * 255f), obj));
    }

    public static void logWarning(object obj, Symbol symbol)
    {
        Debug.LogWarning(symbol.ToString() + obj);
    }

    public static void logWarning(object obj, string prefix)
    {
        Debug.LogWarning(prefix + obj);
    }

    public static void logWarning(object obj, Color color, Symbol symbol)
    {
        Debug.LogWarning(EnumToSymbol(symbol) + string.Format("<color=#{0:X2}{1:X2}{2:X2}>{3}</color>",
            (byte)(color.r * 255f), (byte)(color.g * 255f), (byte)(color.b * 255f), obj));
    }

    public static void logWarning(object obj, Color color, string prefix)
    {
        Debug.LogWarning(prefix + string.Format("<color=#{0:X2}{1:X2}{2:X2}>{3}</color>",
            (byte)(color.r * 255f), (byte)(color.g * 255f), (byte)(color.b * 255f), obj));
    }

    #endregion

    #region ErrorLog

    public static void logError(object obj)
    {
        Debug.LogError(obj);
    }

    public static void logError(object obj, Color color)
    {
        Debug.LogError(string.Format("<color=#{0:X2}{1:X2}{2:X2}>{3}</color>",
            (byte)(color.r * 255f), (byte)(color.g * 255f), (byte)(color.b * 255f), obj));
    }

    public static void logError(object obj, Symbol symbol)
    {
        Debug.LogError(symbol.ToString() + obj);
    }

    public static void logError(object obj, string prefix)
    {
        Debug.LogError(prefix + obj);
    }

    public static void logError(object obj, Color color, Symbol symbol)
    {
        Debug.LogError(EnumToSymbol(symbol) + string.Format("<color=#{0:X2}{1:X2}{2:X2}>{3}</color>",
            (byte)(color.r * 255f), (byte)(color.g * 255f), (byte)(color.b * 255f), obj));
    }

    public static void logError(object obj, Color color, string prefix)
    {
        Debug.LogError(prefix + string.Format("<color=#{0:X2}{1:X2}{2:X2}>{3}</color>",
            (byte)(color.r * 255f), (byte)(color.g * 255f), (byte)(color.b * 255f), obj));
    }

    #endregion
}

public enum Symbol
{
    BlackStar, //★
    WhiteStar, //☆
    BlackFourPointStar, //✦
    WhiteFourPointStar, //✧
    Crosshair, //✢
    OneSidedBracket, //〉
    TwoSidedBracket, //﹞
    Heart, //♡
    Triangle, //▶
    Radiation, //☢
    Error, //⛔
    Warning //⚠️
}